package com.lmk.homework;

import java.util.Scanner;

public class work02 {
    public static void main(String[] args) {
        Scanner c=new Scanner(System.in);
        int year=0;
        int mouth=0;
        int days=0;
        System.out.println("请输入年份" );
        year=c.nextInt();
        System.out.println("请输入月份");
        mouth=c.nextInt();


        switch (mouth){
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                days=31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                days=30;
                break;
            case 2:
               days=isLeap(year)?29:28;//三元运算符
                break;

        }
        System.out.println("你输入的"+year+"年"+mouth+"月是"+days+"天");
    }

    /**用于判断是否为闰年
     *
     */


    static boolean  isLeap(int year){
        if (year%4==0&&year%100!=0||year%400==0){
            return true;}

           return  false;

    }
}
